var Joinactivity = function() {


    // 参会活动人员
    var joinactivityDatalist_url = $('.joinactivityDatalist_url').val();

    var isLoadJoinactivityTable = isLoadMemberTable = false;


    var initJoinactivityTable = function() {
        var table = $('#joinactivity-datatable');
        var activityId = $('.activityId').val();

        if(table.length > 0){
            table.dataTable({
                "processing": true,
                "ordering": false, // 禁止排序
                serverSide: true,// 开启服务器模式
                "ajax": {
                    url: joinactivityDatalist_url,
                    data: {
                        'id' : activityId,
                    }
                },
                "autoWidth": false,
                "columns": [
                    {
                        "data": "avatar",
                        "render": function(data, type, row, meta) {
                            var html = '<div style="float: left;"><img src="'+data+'" class="img-circle" style="width: 70px;height: 40px;"/></div>';
                            html += '<div style="float: left;">';
                            html += '<div class="text-left">'+row.name+'</div>';
                            html += '<div class="text-left">'+row.createDate+'</div>';
                            html += '</div>';

                            return html;
                        }
                    },
                ],
                "language": {
                    url: '/public/static/admin/pages/datatable_cn.json'
                },
                "lengthMenu": [[10, 20, 50, 100, 150], [10, 20, 50, 100, 150]],
                "pageLength": 10,
                "scrollX":"",
                "destroy": false,
                "stateSave": false,
                "stateSaveParams": function (settings, data) {
                    //
                },
                "columnDefs": [{
                    "orderable": false,
                }],
                "dom": "<'row'<'.col-md-6 col-sm-12'><'col-md-6 col-sm-12'>r>" +
                "<t>" +
                "<'relative'<'col-md-5'i><'col-md-7'>lp>",
                "fnInitComplete": function() {
                    var nTrs = table.fnGetNodes();//fnGetNodes获取表格所有行，nTrs[i]表示第i行tr对象
                },
                "fnDrawCallback": function ( oSettings ) {
                    $(oSettings.nTHead).hide();
                }
            });

            isLoadJoinactivityTable = true;
        }
    };


    return {
        init: function() {

            this.onEvent();
        },

        onEvent: function() {

            $('.join-tab').on('click', function(){
                if(!isLoadJoinactivityTable){
                    initJoinactivityTable();
                }
            });
        }

    };

}();

jQuery(document).ready(function() {
    Joinactivity.init();

});